public class CountNum {
    public static void main(String[] args) {
        int[] nums = new int[]{3,2,3};
        int n = majorityElement(nums);
        System.out.println(n);
    }
    public static int majorityElement(int[] nums) {
        int count = 0;
        for(int i = 0;i<nums.length;i++) {
            for(int j = i;j<nums.length;j++) {
                if(nums[i] == nums[j]) {
                    count++;
                }
            }
            if(count > nums.length/2) {
                return nums[i];
            }
            count = 0;
        }
        return count;
    }
}
